From: Keir Fraser Date: Mon, 21 Dec 2009 10:39:48 +0000 (+0000) Subject: xenstore: Fix memory leak in command 'xenstore rm' X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12839 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=80031349d5d6c9eda98781bdc7346739bdca8143;p=xen.git xenstore: Fix memory leak in command 'xenstore rm' When option '-t' is used to do tidy remove, routine xs_directory() will be called in order to check there are brother directories or not. The returned pointer should be passed to free() after this check. Signed-off-by: Yu Zhiguo --- diff --git a/tools/xenstore/xenstore_client.c b/tools/xenstore/xenstore_client.c index aaf3014d53..50fc3d7646 100644 --- a/tools/xenstore/xenstore_client.c +++ b/tools/xenstore/xenstore_client.c @@ -343,8 +343,10 @@ perform(enum mode mode, int optind, int argc, char **argv, struct xs_handle *xsh unsigned int num; char ** list = xs_directory(xsh, xth, p, &num); - if (list && num == 0) { - goto again; + if (list) { + free(list); + if (num == 0) + goto again; } } }